﻿<RibbonWindow xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:WindowManager="clr-namespace:WindowManager"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                     xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:Controls="clr-namespace:WindowManager.Controls"
                     x:Class="WindowManager.MainWindow" mc:Ignorable="d"
                     xmlns:TaskbarNotification="clr-namespace:Hardcodet.Wpf.TaskbarNotification;assembly=Hardcodet.Wpf.TaskbarNotification"
                     xmlns:Settings="clr-namespace:WindowManager.Core.Settings" Title="WindowManager" Height="767" Width="737" Icon="/Assets/Logo.ico" StateChanged="RibbonWindowStateChanged">

    <RibbonWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Themes/Generic.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </RibbonWindow.Resources>

    <RibbonWindow.CommandBindings>
        <CommandBinding Command="WindowManager:CustomCommands.Exit" Executed="CloseWindowMenuItemClick" />
        <CommandBinding Command="WindowManager:CustomCommands.ShowWindow" Executed="ShowWindowMenuItemClick" />
        <CommandBinding Command="WindowManager:CustomCommands.ExportSettings" Executed="ExportSettingsMenuItemClick" />
        <CommandBinding Command="WindowManager:CustomCommands.ImportSettings" Executed="ImportSettingsMenuItemClick" />
    </RibbonWindow.CommandBindings>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Ribbon>
            <Ribbon.ApplicationMenu>
                <RibbonApplicationMenu>
                    <RibbonApplicationMenu.SmallImageSource>
                        <DrawingImage>
                            <DrawingImage.Drawing>
                                <GlyphRunDrawing ForegroundBrush="White">
                                    <GlyphRunDrawing.GlyphRun>
                                        <GlyphRun CaretStops="{x:Null}" ClusterMap="{x:Null}" IsSideways="False"
                              GlyphOffsets="{x:Null}" GlyphIndices="41 76 79 72" FontRenderingEmSize="12" DeviceFontName="{x:Null}"
                              AdvanceWidths="5.859375 2.90625 2.90625 6.275390625">
                                            <GlyphRun.GlyphTypeface>
                                                <GlyphTypeface FontUri="C:\WINDOWS\Fonts\SEGOEUI.TTF" />
                                            </GlyphRun.GlyphTypeface>
                                        </GlyphRun>
                                    </GlyphRunDrawing.GlyphRun>
                                </GlyphRunDrawing>
                            </DrawingImage.Drawing>
                        </DrawingImage>
                    </RibbonApplicationMenu.SmallImageSource>
                    <RibbonApplicationMenuItem Header="Exit"
                                            Command="WindowManager:CustomCommands.Exit" />
                </RibbonApplicationMenu>
            </Ribbon.ApplicationMenu>
            <RibbonTab Header="Home">
                <RibbonGroup Header="Configuration">
                    <RibbonButton LargeImageSource="/Assets/Save.png" Label="Save" Click="SaveClick" />
                    <RibbonButton LargeImageSource="/Assets/Undo.png" Label="Reset" Click="ResetClick" />
                    <RibbonButton LargeImageSource="/Assets/Delete.png" Label="Default Configuration"
                               Click="DefaultSettingsClick" />
                </RibbonGroup>
                <RibbonGroup Header="Profile">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Text="HotKeys: " />
                        <TextBlock Grid.Row="1" Text="Theme: " />

                        <ComboBox Grid.Column="1" x:Name="_hotKeysComboBox" SelectionChanged="HotKeysChanged"
                      x:FieldModifier="private" />
                        <ComboBox Grid.Column="1" Grid.Row="1" x:Name="_themeComboBox" SelectionChanged="ThemeChanged"
                      x:FieldModifier="private" />

                        <RibbonButton Grid.Column="2" SmallImageSource="/Assets/Add.png"
                                 Click="CreateHotkeys" />
                        <RibbonButton Grid.Column="3" SmallImageSource="/Assets/Delete.png"
                                 Click="DeleteHotKeys" />

                        <RibbonButton Grid.Row="1" Grid.Column="2" SmallImageSource="/Assets/Add.png"
                                 Click="CreateTheme" />
                        <RibbonButton Grid.Row="1" Grid.Column="3" SmallImageSource="/Assets/Delete.png"
                                 Click="DeleteTheme" />
                    </Grid>

                </RibbonGroup>
            </RibbonTab>
            <RibbonTab Header="About">
                <RibbonGroup Header="About">
                    <StackPanel>
                        <TextBlock FontWeight="Bold">
              <Run Text="WindowManager" />
                        </TextBlock>
                        <TextBlock>
              <Run Text="Created by:" />
              <Run Text=" " />
              <Run FontWeight="Bold" Text="Meziantou" />
                        </TextBlock>
                        <TextBlock>
              <Hyperlink NavigateUri="http://www.meziantou.net" RequestNavigate="HandleRequestNavigate">
                http://www.meziantou.net
              </Hyperlink>
                        </TextBlock>
                    </StackPanel>
                </RibbonGroup>
            </RibbonTab>
        </Ribbon>


        <TaskbarNotification:TaskbarIcon IconSource="/Assets/Logo.ico" ToolTipText="Window Manager"
                                     x:Name="_taskBarIcon" DoubleClickCommand="WindowManager:CustomCommands.ShowWindow" x:FieldModifier="private">
            <TaskbarNotification:TaskbarIcon.TrayToolTip>
                <ToolTip>
                    <TextBlock Text="Window Manager" />
                </ToolTip>
            </TaskbarNotification:TaskbarIcon.TrayToolTip>
            <TaskbarNotification:TaskbarIcon.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Open" Click="ShowWindowMenuItemClick" />
                    <MenuItem Header="Close" Click="CloseWindowMenuItemClick" />
                </ContextMenu>
            </TaskbarNotification:TaskbarIcon.ContextMenu>
        </TaskbarNotification:TaskbarIcon>

        <Grid Grid.Row="1">

            <Border>
                <Grid x:Name="_settingsGrid" x:FieldModifier="private"
              d:DataContext="{d:DesignInstance Type={x:Type Settings:Settings}}">

                    <Grid.Resources>
                        <Style TargetType="{x:Type CheckBox}">
                            <Setter Property="Margin" Value="3,3,3,3" />
                        </Style>
                        <Style TargetType="{x:Type TextBlock}">
                            <Setter Property="Margin" Value="3,3,3,3" />
                        </Style>
                        <Style TargetType="{x:Type xctk:IntegerUpDown}">
                            <Setter Property="Margin" Value="3,3,3,3" />
                        </Style>
                    </Grid.Resources>

                    <TabControl VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                      ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <TabItem Header="General">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <CheckBox Content="Start when Windows starts"
                          IsChecked="{Binding StartWithWindows, Mode=TwoWay}" />

                                <CheckBox Content="Minimize to tray bar"
                          IsChecked="{Binding MinimizeToTrayBar, Mode=TwoWay}" Grid.Row="1" />

                                <CheckBox Grid.Row="2" Content="Override hot key registered by other applications"
                          IsChecked="{Binding OverrideExistingHotKeys, Mode=TwoWay}" />
                            </Grid>
                        </TabItem>
                        <TabItem Header="HotKeys">
                            <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <TextBlock Grid.Row="0" Text="Top Left: " />
                                    <Controls:HotKeyControl Grid.Row="0" Grid.Column="1"
                                        HotKey="{Binding HotKeys.TopLeftHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="1" Text="Top: " />
                                    <Controls:HotKeyControl Grid.Row="1" Grid.Column="1"
                                        HotKey="{Binding HotKeys.TopHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="2" Text="Top Right: " />
                                    <Controls:HotKeyControl Grid.Row="2" Grid.Column="1"
                                        HotKey="{Binding HotKeys.TopRightHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="3" Text="Center Left: " />
                                    <Controls:HotKeyControl Grid.Row="3" Grid.Column="1"
                                        HotKey="{Binding HotKeys.LeftHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="4" Text="Center: " />
                                    <Controls:HotKeyControl Grid.Row="4" Grid.Column="1"
                                        HotKey="{Binding HotKeys.CenterHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="5" Text="Center Right: " />
                                    <Controls:HotKeyControl Grid.Row="5" Grid.Column="1"
                                        HotKey="{Binding HotKeys.RightHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="6" Text="Bottom Left: " />
                                    <Controls:HotKeyControl Grid.Row="6" Grid.Column="1"
                                        HotKey="{Binding HotKeys.BottomLeftHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="7" Text="Bottom: " />
                                    <Controls:HotKeyControl Grid.Row="7" Grid.Column="1"
                                        HotKey="{Binding HotKeys.BottomHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="8" Text="Bottom Right: " />
                                    <Controls:HotKeyControl Grid.Row="8" Grid.Column="1"
                                        HotKey="{Binding HotKeys.BottomRightHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="9" Text="Horizontal Center: " />
                                    <Controls:HotKeyControl Grid.Row="9" Grid.Column="1"
                                        HotKey="{Binding HotKeys.HorizontalCenterHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="10" Text="Vertical Center: " />
                                    <Controls:HotKeyControl Grid.Row="10" Grid.Column="1"
                                        HotKey="{Binding HotKeys.VerticalCenterHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="11" Text="Full Screen: " />
                                    <Controls:HotKeyControl Grid.Row="11" Grid.Column="1"
                                        HotKey="{Binding HotKeys.FullScreenHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="12" Text="Switch Screen: " />
                                    <Controls:HotKeyControl Grid.Row="12" Grid.Column="1"
                                        HotKey="{Binding HotKeys.SwitchScreenHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="13" Text="Display Position Window: " />
                                    <Controls:HotKeyControl Grid.Row="13" Grid.Column="1"
                                        HotKey="{Binding HotKeys.ShowSizeSelectionWindowHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="14" Text="Top Most: " />
                                    <Controls:HotKeyControl Grid.Row="14" Grid.Column="1"
                                        HotKey="{Binding HotKeys.TopMostHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="15" Text="Bottom Most: " />
                                    <Controls:HotKeyControl Grid.Row="15" Grid.Column="1"
                                        HotKey="{Binding HotKeys.BottomMostHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="16" Text="Extend Left: " />
                                    <Controls:HotKeyControl Grid.Row="16" Grid.Column="1"
                                        HotKey="{Binding HotKeys.ExtendLeftHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="17" Text="Extend Right: " />
                                    <Controls:HotKeyControl Grid.Row="17" Grid.Column="1"
                                        HotKey="{Binding HotKeys.ExtendRightHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="18" Text="Extend Top: " />
                                    <Controls:HotKeyControl Grid.Row="18" Grid.Column="1"
                                        HotKey="{Binding HotKeys.ExtendTopHotKey, Mode=TwoWay}" />
                                    
                                    <TextBlock Grid.Row="19" Text="Extend Bottom: " />
                                    <Controls:HotKeyControl Grid.Row="19" Grid.Column="1"
                                        HotKey="{Binding HotKeys.ExtendBottomHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="20" Text="Reduce Left: " />
                                    <Controls:HotKeyControl Grid.Row="20" Grid.Column="1"
                                        HotKey="{Binding HotKeys.ReduceLeftHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="21" Text="Reduce Right: " />
                                    <Controls:HotKeyControl Grid.Row="21" Grid.Column="1"
                                        HotKey="{Binding HotKeys.ReduceRightHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="22" Text="Reduce Top: " />
                                    <Controls:HotKeyControl Grid.Row="22" Grid.Column="1"
                                        HotKey="{Binding HotKeys.ReduceTopHotKey, Mode=TwoWay}" />

                                    <TextBlock Grid.Row="23" Text="Reduce Bottom: " />
                                    <Controls:HotKeyControl Grid.Row="23" Grid.Column="1"
                                        HotKey="{Binding HotKeys.ReduceBottomHotKey, Mode=TwoWay}" />

                                </Grid>
                            </ScrollViewer>
                        </TabItem>
                        <TabItem Header="Theme">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <CheckBox Grid.ColumnSpan="2" Content="Show size selection window in full screen"
                          IsChecked="{Binding Theme.SwitchWindowFullScreen, Mode=TwoWay}" />

                                <TextBlock Grid.Row="1" Text="Background Color: " />
                                <xctk:ColorPicker Grid.Row="1" Grid.Column="1" DisplayColorAndName="True"
                                  ShowAvailableColors="False" ShowStandardColors="False" Style="{DynamicResource ColorPickerStyle1}"
                                  SelectedColor="{Binding Theme.BackgroundColor, Mode=TwoWay}" HorizontalAlignment="Left" />

                                <TextBlock Grid.Row="2" Text="Foreground Color: " />
                                <xctk:ColorPicker Grid.Row="2" Grid.Column="1" DisplayColorAndName="True"
                                  ShowAvailableColors="False" ShowStandardColors="False" Style="{DynamicResource ColorPickerStyle1}"
                                  SelectedColor="{Binding Theme.ForegroundColor, Mode=TwoWay}" HorizontalAlignment="Left" />

                                <TextBlock Grid.Row="3" Text="Selection Border Color: " />
                                <xctk:ColorPicker Grid.Row="3" Grid.Column="1" DisplayColorAndName="True"
                                  ShowAvailableColors="False" ShowStandardColors="False" Style="{DynamicResource ColorPickerStyle1}"
                                  SelectedColor="{Binding Theme.SelectionBorderColor, Mode=TwoWay}" HorizontalAlignment="Left" />

                                <TextBlock Grid.Row="4" Text="Selection Fill Color: " />
                                <xctk:ColorPicker Grid.Row="4" Grid.Column="1" DisplayColorAndName="True"
                                  ShowAvailableColors="False" ShowStandardColors="False" Style="{DynamicResource ColorPickerStyle1}"
                                  SelectedColor="{Binding Theme.SelectionFillColor, Mode=TwoWay}" HorizontalAlignment="Left" />

                                <TextBlock Grid.Row="5" Text="Rows: " />
                                <xctk:IntegerUpDown Grid.Row="5" Grid.Column="1" Minimum="0" Maximum="20"
                                    Value="{Binding Theme.NbItemsPerColumn, Mode=TwoWay}" HorizontalAlignment="Left" />
                                <TextBlock Grid.Row="6" Text="Columns: " />
                                <xctk:IntegerUpDown Grid.Row="6" Grid.Column="1" Minimum="0" Maximum="20"
                                    Value="{Binding Theme.NbItemsPerRow, Mode=TwoWay}" HorizontalAlignment="Left" />

                            </Grid>
                        </TabItem>
                    </TabControl>
                </Grid>
            </Border>

        </Grid>
    </Grid>
</RibbonWindow>